package com.sskj.boom.bean;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;

import com.sskj.boom.widget.BoomView;

public class EscapeBean {
    private String name;
    private float scale;

    public EscapeBean(String name, float scale) {
        this.name = name;
        this.scale = scale;
    }

    private int disappearTime = 10000;//消失时间

    public void drawName(BoomView boomView, Canvas canvas, int nowTime) {
        float showTime = boomView.getTimeByTimes(scale);
        if (nowTime - showTime > disappearTime) {
            return;
        }
        if (nowTime < showTime) {
            return;
        }
        float time = nowTime - showTime;
        Paint paintText = new Paint();
        paintText.setAntiAlias(true);
        paintText.setColor(Color.argb(255 - (int) time * 255 / disappearTime, 255, 255, 255));
        paintText.setTextAlign(Paint.Align.CENTER);
        paintText.setTextSize(32);

        Paint dotPaint = new Paint();
        dotPaint.setAntiAlias(true);
        dotPaint.setColor(Color.argb(255 - (int) time * 255 / disappearTime, 255, 255, 255));


        float x = boomView.getXByTime(showTime);
        float y = boomView.getYByTime(showTime);
        float startY = boomView.getYByTime(0);
        float nowY = y + time * Math.max(0, startY - y) / disappearTime;
        canvas.drawCircle(x, nowY, 8, dotPaint);


        canvas.drawText(name + "@" + scale, x, nowY + 30, paintText);
    }
}
